home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / CIncludes / Events.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-12  |  9.7 KB  |  344 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Events.h
  3.  
  4.      Contains:    Event Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 8
  7.                  Release:    Universal Interfaces 3.0.1
  8.  
  9.      Copyright:    © 1985-1997 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __EVENTS__
  19. #define __EVENTS__
  20.  
  21. #ifndef __OSUTILS__
  22. #include <OSUtils.h>
  23. #endif
  24. #ifndef __QUICKDRAW__
  25. #include <Quickdraw.h>
  26. #endif
  27. #ifndef __TYPES__
  28. #include <Types.h>
  29. #endif
  30.  
  31.  
  32.  
  33. #if PRAGMA_ONCE
  34. #pragma once
  35. #endif
  36.  
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40.  
  41. #if PRAGMA_IMPORT
  42. #pragma import on
  43. #endif
  44.  
  45. #if PRAGMA_STRUCT_ALIGN
  46.     #pragma options align=mac68k
  47. #elif PRAGMA_STRUCT_PACKPUSH
  48.     #pragma pack(push, 2)
  49. #elif PRAGMA_STRUCT_PACK
  50.     #pragma pack(2)
  51. #endif
  52.  
  53. typedef UInt16                             EventKind;
  54. typedef UInt16                             EventMask;
  55.  
  56. enum {
  57.     nullEvent                    = 0,
  58.     mouseDown                    = 1,
  59.     mouseUp                        = 2,
  60.     keyDown                        = 3,
  61.     keyUp                        = 4,
  62.     autoKey                        = 5,
  63.     updateEvt                    = 6,
  64.     diskEvt                        = 7,
  65.     activateEvt                    = 8,
  66.     osEvt                        = 15,
  67.     kHighLevelEvent                = 23
  68. };
  69.  
  70.  
  71. enum {
  72.     mDownMask                    = 1 << mouseDown,                /* mouse button pressed*/
  73.     mUpMask                        = 1 << mouseUp,                    /* mouse button released*/
  74.     keyDownMask                    = 1 << keyDown,                    /* key pressed*/
  75.     keyUpMask                    = 1 << keyUp,                    /* key released*/
  76.     autoKeyMask                    = 1 << autoKey,                    /* key repeatedly held down*/
  77.     updateMask                    = 1 << updateEvt,                /* window needs updating*/
  78.     diskMask                    = 1 << diskEvt,                    /* disk inserted*/
  79.     activMask                    = 1 << activateEvt,                /* activate/deactivate window*/
  80.     highLevelEventMask            = 0x0400,                        /* high-level events (includes AppleEvents)*/
  81.     osMask                        = 1 << osEvt,                    /* operating system events (suspend, resume)*/
  82.     everyEvent                    = 0xFFFF                        /* all of the above*/
  83. };
  84.  
  85.  
  86. enum {
  87.     charCodeMask                = 0x000000FF,
  88.     keyCodeMask                    = 0x0000FF00,
  89.     adbAddrMask                    = 0x00FF0000,
  90.     osEvtMessageMask            = (long)0xFF000000
  91. };
  92.  
  93.  
  94. enum {
  95.                                                                 /* OS event messages.  Event (sub)code is in the high byte of the message field.*/
  96.     mouseMovedMessage            = 0x00FA,
  97.     suspendResumeMessage        = 0x0001
  98. };
  99.  
  100.  
  101. enum {
  102.     resumeFlag                    = 1,                            /* Bit 0 of message indicates resume vs suspend*/
  103.     convertClipboardFlag        = 2                                /* Bit 1 in resume message indicates clipboard change*/
  104. };
  105.  
  106.  
  107. typedef UInt16                             EventModifiers;
  108.  
  109. enum {
  110.                                                                 /* modifiers */
  111.     activeFlagBit                = 0,                            /* activate? (activateEvt and mouseDown)*/
  112.     btnStateBit                    = 7,                            /* state of button?*/
  113.     cmdKeyBit                    = 8,                            /* command key down?*/
  114.     shiftKeyBit                    = 9,                            /* shift key down?*/
  115.     alphaLockBit                = 10,                            /* alpha lock down?*/
  116.     optionKeyBit                = 11,                            /* option key down?*/
  117.     controlKeyBit                = 12,                            /* control key down?*/
  118.     rightShiftKeyBit            = 13,                            /* right shift key down?*/
  119.     rightOptionKeyBit            = 14,                            /* right Option key down?*/
  120.     rightControlKeyBit            = 15                            /* right Control key down?*/
  121. };
  122.  
  123.  
  124. enum {
  125.     activeFlag                    = 1 << activeFlagBit,
  126.     btnState                    = 1 << btnStateBit,
  127.     cmdKey                        = 1 << cmdKeyBit,
  128.     shiftKey                    = 1 << shiftKeyBit,
  129.     alphaLock                    = 1 << alphaLockBit,
  130.     optionKey                    = 1 << optionKeyBit,
  131.     controlKey                    = 1 << controlKeyBit,
  132.     rightShiftKey                = 1 << rightShiftKeyBit,
  133.     rightOptionKey                = 1 << rightOptionKeyBit,
  134.     rightControlKey                = 1 << rightControlKeyBit
  135. };
  136.  
  137.  
  138. enum {
  139.     kNullCharCode                = 0,
  140.     kHomeCharCode                = 1,
  141.     kEnterCharCode                = 3,
  142.     kEndCharCode                = 4,
  143.     kHelpCharCode                = 5,
  144.     kBellCharCode                = 7,
  145.     kBackspaceCharCode            = 8,
  146.     kTabCharCode                = 9,
  147.     kLineFeedCharCode            = 10,
  148.     kVerticalTabCharCode        = 11,
  149.     kPageUpCharCode                = 11,
  150.     kFormFeedCharCode            = 12,
  151.     kPageDownCharCode            = 12,
  152.     kReturnCharCode                = 13,
  153.     kFunctionKeyCharCode        = 16,
  154.     kEscapeCharCode                = 27,
  155.     kClearCharCode                = 27,
  156.     kLeftArrowCharCode            = 28,
  157.     kRightArrowCharCode            = 29,
  158.     kUpArrowCharCode            = 30,
  159.     kDownArrowCharCode            = 31,
  160.     kDeleteCharCode                = 127,
  161.     kNonBreakingSpaceCharCode    = 202
  162. };
  163.  
  164. struct EventRecord {
  165.     EventKind                         what;
  166.     UInt32                             message;
  167.     UInt32                             when;
  168.     Point                             where;
  169.     EventModifiers                     modifiers;
  170. };
  171. typedef struct EventRecord EventRecord;
  172.  
  173.  
  174. typedef CALLBACK_API( void , FKEYProcPtr )(void );
  175. typedef STACK_UPP_TYPE(FKEYProcPtr)                             FKEYUPP;
  176. enum { uppFKEYProcInfo = 0x00000000 };                             /* pascal no_return_value Func() */
  177. #define NewFKEYProc(userRoutine)                                 (FKEYUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppFKEYProcInfo, GetCurrentArchitecture())
  178. #define CallFKEYProc(userRoutine)                                 CALL_ZERO_PARAMETER_UPP((userRoutine), uppFKEYProcInfo)
  179. EXTERN_API( void )
  180. GetMouse                        (Point *                mouseLoc)                            ONEWORDINLINE(0xA972);
  181.  
  182. EXTERN_API( Boolean )
  183. Button                            (void)                                                        ONEWORDINLINE(0xA974);
  184.  
  185. EXTERN_API( Boolean )
  186. StillDown                        (void)                                                        ONEWORDINLINE(0xA973);
  187.  
  188. EXTERN_API( Boolean )
  189. WaitMouseUp                        (void)                                                        ONEWORDINLINE(0xA977);
  190.  
  191. EXTERN_API( UInt32 )
  192. TickCount                        (void)                                                        ONEWORDINLINE(0xA975);
  193.  
  194. EXTERN_API( UInt32 )
  195. KeyTranslate                    (const void *            transData,
  196.                                  UInt16                 keycode,
  197.                                  UInt32 *                state)                                ONEWORDINLINE(0xA9C3);
  198.  
  199. EXTERN_API( UInt32 )
  200. GetCaretTime                    (void)                                                        TWOWORDINLINE(0x2EB8, 0x02F4);
  201.  
  202.  
  203. typedef UInt32                             KeyMap[4];
  204. EXTERN_API( void )
  205. GetKeys                            (KeyMap                 theKeys)                            ONEWORDINLINE(0xA976);
  206.  
  207.  
  208.  
  209. /* Obsolete event types & masks */
  210.  
  211. enum {
  212.     networkEvt                    = 10,
  213.     driverEvt                    = 11,
  214.     app1Evt                        = 12,
  215.     app2Evt                        = 13,
  216.     app3Evt                        = 14,
  217.     app4Evt                        = 15,
  218.     networkMask                    = 0x0400,
  219.     driverMask                    = 0x0800,
  220.     app1Mask                    = 0x1000,
  221.     app2Mask                    = 0x2000,
  222.     app3Mask                    = 0x4000,
  223.     app4Mask                    = 0x8000
  224. };
  225.  
  226. struct EvQEl {
  227.     QElemPtr                         qLink;
  228.     SInt16                             qType;
  229.     EventKind                         evtQWhat;                    /* this part is identical to the EventRecord as defined above */
  230.     UInt32                             evtQMessage;
  231.     UInt32                             evtQWhen;
  232.     Point                             evtQWhere;
  233.     EventModifiers                     evtQModifiers;
  234. };
  235. typedef struct EvQEl EvQEl;
  236.  
  237. typedef EvQEl *                            EvQElPtr;
  238. typedef CALLBACK_API( void , GetNextEventFilterProcPtr )(EventRecord *theEvent, Boolean *result);
  239. /*
  240.     WARNING: GetNextEventFilterProcPtr uses register based parameters under classic 68k
  241.              and cannot be written in a high-level language without 
  242.              the help of mixed mode or assembly glue.
  243. */
  244. typedef REGISTER_UPP_TYPE(GetNextEventFilterProcPtr)             GetNextEventFilterUPP;
  245. enum { uppGetNextEventFilterProcInfo = 0x000000BF };             /* SPECIAL_CASE_PROCINFO(11) */
  246. #define NewGetNextEventFilterProc(userRoutine)                     (GetNextEventFilterUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppGetNextEventFilterProcInfo, GetCurrentArchitecture())
  247. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  248.     /* CallGetNextEventFilterProc can't be called from classic 68k without glue code */
  249. #else
  250.     #define CallGetNextEventFilterProc(userRoutine, theEvent, result)  CALL_TWO_PARAMETER_UPP((userRoutine), uppGetNextEventFilterProcInfo, (theEvent), (result))
  251. #endif
  252. typedef GetNextEventFilterUPP             GNEFilterUPP;
  253. EXTERN_API( QHdrPtr )
  254. GetEvQHdr                        (void)                                                        THREEWORDINLINE(0x2EBC, 0x0000, 0x014A);
  255.  
  256. EXTERN_API( UInt32 )
  257. GetDblTime                        (void)                                                        TWOWORDINLINE(0x2EB8, 0x02F0);
  258.  
  259. EXTERN_API( void )
  260. SetEventMask                    (EventMask                 value)                                TWOWORDINLINE(0x31DF, 0x0144);
  261.  
  262.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  263.                                                                                             #pragma parameter __D0 PPostEvent(__A0, __D0, __A1)
  264.                                                                                             #endif
  265. EXTERN_API( OSErr )
  266. PPostEvent                        (EventKind                 eventCode,
  267.                                  UInt32                 eventMsg,
  268.                                  EvQElPtr *                qEl)                                TWOWORDINLINE(0xA12F, 0x2288);
  269.  
  270. #define KeyTrans(transData, keycode, state) KeyTranslate(transData, keycode, state)
  271. EXTERN_API( Boolean )
  272. GetNextEvent                    (EventMask                 eventMask,
  273.                                  EventRecord *            theEvent)                            ONEWORDINLINE(0xA970);
  274.  
  275. EXTERN_API( Boolean )
  276. WaitNextEvent                    (EventMask                 eventMask,
  277.                                  EventRecord *            theEvent,
  278.                                  UInt32                 sleep,
  279.                                  RgnHandle                 mouseRgn)                            ONEWORDINLINE(0xA860);
  280.  
  281. EXTERN_API( Boolean )
  282. EventAvail                        (EventMask                 eventMask,
  283.                                  EventRecord *            theEvent)                            ONEWORDINLINE(0xA971);
  284.  
  285.  
  286.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  287.                                                                                             #pragma parameter __D0 PostEvent(__A0, __D0)
  288.                                                                                             #endif
  289. EXTERN_API( OSErr )
  290. PostEvent                        (EventKind                 eventNum,
  291.                                  UInt32                 eventMsg)                            ONEWORDINLINE(0xA02F);
  292.  
  293.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  294.                                                                                             #pragma parameter __D0 OSEventAvail(__D0, __A0)
  295.                                                                                             #endif
  296. EXTERN_API( Boolean )
  297. OSEventAvail                    (EventMask                 mask,
  298.                                  EventRecord *            theEvent)                            TWOWORDINLINE(0xA030, 0x5240);
  299.  
  300.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  301.                                                                                             #pragma parameter __D0 GetOSEvent(__D0, __A0)
  302.                                                                                             #endif
  303. EXTERN_API( Boolean )
  304. GetOSEvent                        (EventMask                 mask,
  305.                                  EventRecord *            theEvent)                            TWOWORDINLINE(0xA031, 0x5240);
  306.  
  307. EXTERN_API( void )
  308. FlushEvents                        (EventMask                 whichMask,
  309.                                  EventMask                 stopMask)                            TWOWORDINLINE(0x201F, 0xA032);
  310.  
  311. EXTERN_API( void )
  312. SystemClick                        (const EventRecord *    theEvent,
  313.                                  WindowPtr                 theWindow)                            ONEWORDINLINE(0xA9B3);
  314.  
  315. EXTERN_API( void )
  316. SystemTask                        (void)                                                        ONEWORDINLINE(0xA9B4);
  317.  
  318. EXTERN_API( Boolean )
  319. SystemEvent                        (const EventRecord *    theEvent)                            ONEWORDINLINE(0xA9B2);
  320.  
  321.  
  322.  
  323.  
  324. #if PRAGMA_STRUCT_ALIGN
  325.     #pragma options align=reset
  326. #elif PRAGMA_STRUCT_PACKPUSH
  327.     #pragma pack(pop)
  328. #elif PRAGMA_STRUCT_PACK
  329.     #pragma pack()
  330. #endif
  331.  
  332. #ifdef PRAGMA_IMPORT_OFF
  333. #pragma import off
  334. #elif PRAGMA_IMPORT
  335. #pragma import reset
  336. #endif
  337.  
  338. #ifdef __cplusplus
  339. }
  340. #endif
  341.  
  342. #endif /* __EVENTS__ */
  343.  
  344.